<?php
class ThumbPic extends Action {
	/*
	 * (non-PHPdoc) @see Action::execute()
	 */
	public function execute($params) {
		check_login ( ADMIN_LOGIN_PAGE );
		$data ['success'] = false;
		$aid = safe_ids ( rqst ( 'aid' ), ',', true );
		if ($aid) {
			$atM = new WebAttachmentModel ();
			$atts = $atM->where ( array ('attachment_id IN' => $aid,'type' => 'image' ) )->retrieve ( 'attachment_id,url,type' );
			$cnt = 0;
			if ($atts) {
				foreach ( $atts as $att ) {
					$thumb = new ImageUtil ( WWW_ROOT . $att ['url'] );
					$rst = $thumb->thumbnail ( array (array (80,60 ),array (260,180 ) ) );
					$data ['rst'] ['a'.$att ['attachment_id']] = $rst;
				}
			}
			$data ['success'] = true;
		} else {
			$data ['msg'] = "错误的附件编号";
		}
		return new JsonView ( $data );
	}
}